#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/7/26 16:29
# @Author  : Jet
# @Email   : jyan@abot.cn
# @File    : my_dir_test.py

import os, time

g_abot_working_dir = os.getcwd()

file_dir = "static"
filename = "test.jpg"
file_new_name = "test_new.jpg"

# 路径追加年份
current_year = time.localtime().tm_year

# 路径追加月份
current_month = time.localtime().tm_mon

# 自动补零，比如 4月份，为 04月份
file_dir += str(current_month).zfill(2) + '/'
if not os.path.exists(os.path.join(g_abot_working_dir, file_dir)):
    os.mkdir(os.path.join(g_abot_working_dir, file_dir))

filename_and_path = os.path.join(g_abot_working_dir, file_dir) + filename

print('filename and path ===>>> ' + filename_and_path)
print('所在目录 ===>>> ' + os.path.dirname(filename_and_path))

# 获取文件扩展名
file_ext_name = os.path.splitext(filename)[-1]

# 拼接文件路径
file_path_name = os.path.join(g_abot_working_dir, file_dir, file_new_name)

print(file_ext_name)
print(file_path_name)


